# 基于最新的 php-fpm 构建
FROM php:7.4-fpm

# 更新一下 apt-get, 需要通过它来安装一些必备工具
# RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak
# 实测都更新不了了，不行
# COPY sources.list /etc/apt/
RUN apt-get update -y

# 安装 git, zip, unzip(composer 要用到), freetype等(gd 用到), libzip-dev(php zip 扩展用到)
RUN apt-get install -y git libzip-dev zip unzip libfreetype6-dev libjpeg62-turbo-dev cron vim
RUN /etc/init.d/cron start

# 安装 pdo_mysql 扩展，默认是没有的
RUN pecl install redis && docker-php-ext-enable redis && docker-php-ext-install pdo_mysql bcmath gd zip

# 安装 composer
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
RUN php composer-setup.php
RUN mv composer.phar /usr/local/bin/composer
RUN chmod +x /usr/local/bin/composer 

# 设置 composer 代理镜像
RUN composer config -g repo.packagist composer https://mirrors.aliyun.com/composer
